package com.xingshang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xingshang.mapper.InvoiceMapper;
import com.xingshang.model.po.Invoice;
import com.xingshang.service.InvoiceService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InvoiceServiceImpl extends ServiceImpl<InvoiceMapper, Invoice> implements InvoiceService {

    @Override
    public List<Invoice> getInvoicesByUserId(Integer userId) {
        return query().eq("user_id", userId).list();
    }

    @Override
    public Invoice getInvoiceById(Integer id) {
        return getById(id);
    }

    @Override
    public int addInvoice(Invoice invoice) {
        return save(invoice) ? 1 : 0;
    }

    @Override
    public int updateInvoice(Invoice invoice) {
        return updateById(invoice) ? 1 : 0;
    }

    @Override
    public int deleteInvoiceById(Integer id) {
        return removeById(id) ? 1 : 0;
    }
}
